package tq.com.tqteacher.discuss.factory;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import tq.com.tqteacher.discuss.vh.TQLeftViewHold;
import tq.com.tqteacher.discuss.vh.TQRightViewHold;
import tq.com.tqteacher.discuss.vh.TQSelectLeftViewHold;
import tq.com.tqteacher.discuss.vh.TQSelectRightViewHold;
import tq.com.tqteacher.model.TQCommentOverInfoModel;
import tq.com.tqteacher.model.TQLogin;

public class TQDiscussFactory {
    final static public int TYPE_RIGHT= 0x00;
    final static public int TYPE_Left= 0x01;

    static public RecyclerView.ViewHolder getInstance(int type, Context pContext, ViewGroup pViewGroup){
        RecyclerView.ViewHolder lViewHolder = null;
        switch (type){
            case TYPE_RIGHT:{
                lViewHolder = TQRightViewHold.instance(pContext, pViewGroup);
            }break;
            case TYPE_Left:{
                lViewHolder = TQLeftViewHold.instance(pContext, pViewGroup);
            }break;

        }
        return lViewHolder;
    }

    static public RecyclerView.ViewHolder getSelectInstance(int type, Context pContext, ViewGroup pViewGroup){
        RecyclerView.ViewHolder lViewHolder = null;
        switch (type){
            case TYPE_RIGHT:{
                lViewHolder = TQSelectRightViewHold.instance(pContext, pViewGroup);
            }break;
            case TYPE_Left:{
                lViewHolder = TQSelectLeftViewHold.instance(pContext, pViewGroup);
            }break;

        }
        return lViewHolder;
    }

    static public int getDirectory(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel){
        if(pInfoModel == null || pInfoModel.getUserInfo() == null) return TYPE_Left;

        if(TQLogin.getCurrent().getUserInfo().getId() == pInfoModel.getUserInfo().getId()){
            return TYPE_RIGHT;
        }
        return TYPE_Left;
    }
}
